import { defineConfig } from 'vite';

import uni from '@dcloudio/vite-plugin-uni';
import TransformPages from 'uni-read-pages-vite';
import AutoImport from 'unplugin-auto-import/vite';
import Unocss from 'unocss/vite';

export default defineConfig({
	plugins: [
		uni(),
		Unocss(),
		AutoImport({
			imports: [
				'vue',
				'uni-app',
				'pinia',
				{
					from: 'uni-mini-router',
					imports: ['createRouter', 'useRouter', 'useRoute'],
				},
			],
			dts: 'types/auto-imports.d.ts', // 使用typescript，需要指定生成对应的d.ts文件或者设置为true,生成默认导入d.ts文件
			dirs: ['src/store', 'src/composables', 'src/hooks'],
			eslintrc: {
				enabled: true,
				globalsPropValue: true,
			},
		}),
	],
	define: {
		ROUTES: new TransformPages().routes, // 注入路由表
	},
});
